package duotai;

public class lianxi {
    public static void main(String[] args) {
        Income[] incomes = new Income[]{
                new Income(3000),
                new salary(10009),
                new gaofei(12000),
        };
        System.out.println(totalTxt(incomes));
    }
    public static double totalTxt(Income...incomes) {
        double total = 0;
        for(Income income : incomes) {
            total += income.getTax();
        }
        return total;
    }
}
class Incomes{
    protected double income;
    public void Income(double income){
        this.income = income;
    }
    public double getTax() {
        return income * 0.1; // 税率10%
    }

}
class salary extends Income{
    public salary(double income) {
        super(income);
    }
    @Override
    public double getTax() {

        if (income <= 5000) {
            return 0;
        }
        return (income - 5000) * 0.2;
    }

}
class gaofei extends Income{
    protected double incomes;
    public  gaofei(double incomes){
        super(incomes);
    }

    @Override
    public double getTax() {
        return incomes*0.2;
    }
}
